import re
from copy import deepcopy
xdata = [
    ['小泉纯一郎', '小犬'],
    ['毛泽东', '润之'],
    [None, None],
    ['毛泽东', '毛主席'],
    ['平', None],
    ['刘备', '大耳'],
    [None, '习近平'],
    ['刘皇叔', '刘玄德'],
    ['刘备', '刘玄德'],
    ['金三胖', '金正恩'],
    [None, '金正日'],
    ['金正日', '金二胖'],
]
h,output=[],[]
for i in xdata:
    if None in i:
        i.remove(None)
    h.append(set(i))
h.remove({None})
for i in h:
    while True:
        i_=deepcopy(i)
        for i0 in h:
            if i&i0==set():
                continue
            else:
                i=i|i0
        if i==i_:
            break
    output.append(i)
o = []
for i in output:
    o_str = str(i)
    o_str = re.sub(r"[{}\']", "", o_str)  # Remove braces and quotes
    o_tuple = tuple(o_str.split(", "))  # Convert to tuple
    o.append(o_tuple)

o_set = set(o)
print(o_set)
